//
//  EFMyCollectionNoteViewCell.m
//  EnjogFood
//
//  Created by guocheng on 2017/5/8.
//  Copyright © 2017年 wf. All rights reserved.
//

#import "EFMyCollectionNoteViewCell.h"
#import "EFMyCollectionNoteViewItem.h"

@interface EFMyCollectionNoteViewCell()

@property(strong,nonatomic) UIImageView* goodsIV;
@property(strong,nonatomic) UILabel* titleLabel;
@property(strong,nonatomic) UILabel* dateLabel;
@property(strong,nonatomic) UIImageView* userIV;
@property(strong,nonatomic) UILabel* userNameLabel;

@end

@implementation EFMyCollectionNoteViewCell



-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self){
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.contentView.backgroundColor = [UIColor clearColor];
        self.backgroundColor = [UIColor whiteColor];
        [self initView];
    }
    return self;
}

-(void)setObject:(EFMyCollectionNoteViewItem *)item{
    
    [self.titleLabel setText:item.title];
    [self.titleLabel sizeToFit];
   
    
    [self.dateLabel setText:item.date];
    [self.dateLabel sizeToFit];
    
    [self.userNameLabel setText:item.userName];
    [self.userNameLabel sizeToFit];
    
}

-(void)initView{
    [self.contentView addSubview:self.goodsIV];
    [self.contentView addSubview:self.titleLabel];
    [self.contentView addSubview:self.dateLabel];
    [self.contentView addSubview:self.userIV];
    [self.contentView addSubview:self.userNameLabel];
}

-(void)layoutSubviews{
    [super layoutSubviews];
    self.goodsIV.width = 102;
    self.goodsIV.height = 102;
    self.goodsIV.left = 20;
    self.goodsIV.top = 19;
    
    self.titleLabel.left = self.goodsIV.right + 9;
    self.titleLabel.top = 6;
    self.titleLabel.height = 20;
    self.titleLabel.width= kScreenWidth - self.goodsIV.width - 30;
    
    self.dateLabel.top = self.titleLabel.bottom + 1;
    self.dateLabel.left = self.goodsIV.right + 9;
    
    self.userNameLabel.top = self.dateLabel.bottom + 21;
    self.userNameLabel.left = self.goodsIV.right + 36;

}

-(UIImageView*)goodsIV{
    if(_goodsIV == NULL){
        _goodsIV = [[UIImageView alloc] init];
        _goodsIV.backgroundColor = RGBCOLOR(0xf3f3f3);
        _goodsIV.contentMode = UIViewContentModeScaleAspectFill;
        _goodsIV.clipsToBounds = YES;
    }
    return _goodsIV;
}

-(UILabel*)titleLabel{
    if(_titleLabel == NULL){
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.font = [UIFont systemFontOfSize:15];
        _titleLabel.textColor  = kBlack333;
        _titleLabel.lineBreakMode  = NSLineBreakByTruncatingTail;
        _titleLabel.numberOfLines = 0 ;
    }
    return _titleLabel;
}

-(UILabel*)dateLabel{
    if(_dateLabel == NULL){
        _dateLabel = [[UILabel alloc] init];
        _dateLabel.font = [UIFont systemFontOfSize:13];
        _dateLabel.textColor  = kBlack999;
    }
    return _dateLabel;
}


-(UIImageView*)userIV{
    if(_userIV == NULL){
        _userIV = [[UIImageView alloc] init];
        _userIV.contentMode = UIViewContentModeScaleAspectFill;
        _userIV.clipsToBounds = YES;
    }
    return _userIV;
}


-(UILabel*)userNameLabel{
    if(_userNameLabel == NULL){
        _userNameLabel = [[UILabel alloc] init];
        _userNameLabel.font = [UIFont systemFontOfSize:13];
        _userNameLabel.textColor  = kBlack333;
    }
    return _userNameLabel;
}


@end
